<template>
    <view class="set">
        <image src="../../../static/imgs/mine/setBg.png" mode="" class="setBg"></image>
        <view class="title susPen">
            蓝鲸微聘
        </view>

        <view class="safeCenter susPen">
            账号安全中心
        </view>

        <view class="content">
            <view class="setItem" @tap="goAccount">
                <view class="setName smTitle">
                    账号管理
                </view>

                <image src="../../../static/imgs/right.png" mode=""></image>
            </view>

            <view class="setItem" @tap="goPower">
                <view class="setName smTitle">
                    权限管理
                </view>

                <image src="../../../static/imgs/right.png" mode=""></image>
            </view>

            <view class="setItem" @click="_toUrl('/index/index/document/id/1.html')">
                <view class="setName smTitle">
                    服务协议
                </view>

                <image src="../../../static/imgs/right.png" mode=""></image>
            </view>

            <view class="setItem" @click="_toUrl('/index/index/document/id/3.html')">
                <view class="setName smTitle">
                    隐私政策
                </view>

                <image src="../../../static/imgs/right.png" mode=""></image>
            </view>

            <view class="setItem" @tap="delUser">
                <view class="setName smTitle">
                    注销账号
                </view>

                <image src="../../../static/imgs/right.png" mode=""></image>
            </view>

            <!-- 点击退出登录 -->
            <view class="login">
                <u-button type="info" :plain="true" size="large" shape="circle" @click="loginOut">退出登录</u-button>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {

            }
        },
        methods: {
            loginOut() {
                console.log(111);
                uni.showModal({
                    title: '确定退出登录吗？',
                    duration: 2000,
                    success: function(res) {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.clearStorageSync();
                            uni.reLaunch({
                                url: '/pages/login/login'
                            })
                        }
                    }
                })
            },
            
            delUser() {
                uni.showModal({
                    title: '确定要注销账号吗？',
                    content: '确认注销将清除您的账号数据，该操作不可恢复',
                    duration: 2000,
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            this._ajax({
                                url: '/api/user/delUser',
                                success: res => {
                                    this._toast(res.msg);
                                    if(res.code == 1) {
                                        setTimeout(() => {
                                            uni.clearStorageSync();
                                            uni.reLaunch({
                                                url: '/pages/login/login'
                                            });
                                        }, 1000);
                                    }
                                }
                            }, 1);
                        }
                    }
                })
            },

            goAccount() {
                uni.navigateTo({
                    url: '/pages/views/mine/account'
                })
            },
            goPower() {
                uni.navigateTo({
                    url: '/pages/views/mine/power'
                })
            }
        }
    }
</script>

<style scoped lang='less'>
    .set {
        width: 100%;
        position: relative;

        .setBg {
            width: 100%;
            height: 316upx;
        }

        .title {
            font-size: 60upx;
            color: #FFFFFF;
            top: 60upx;
        }

        .safeCenter {
            font-size: 40upx;
            color: #FFFFFF;
            top: 150upx;
        }

        .susPen {
            position: absolute;
            left: 52upx;
            z-index: 10;
        }

        .content {
            padding: 0 48upx;

            .setItem {
                width: 100%;
                height: 120upx;
                border-bottom: 1px solid #E5E5E5;
                display: flex;
                align-items: center;
                justify-content: space-between;

                image {
                    width: 48upx;
                    height: 48upx;
                }
            }

            .login {
                margin-top: 130upx;
                font-size: 32rpx;
            }
        }
    }
</style>
